let dump_tokens infilename =
  let channel = open_in infilename in
  let lexbuf = Lexing.from_channel channel in
  let stop = ref false in
  while not !stop do
    let t = Lexer.token lexbuf in
    match t with
      | Parser.SECTION s -> Format.printf " [%s]@\n" s
      | Parser.OPTION (o, v) -> Format.printf "   %s=%s$@\n" o v
      | Parser.EOF -> stop := true; Format.printf "@\n@\n"
  done
;;

Format.printf "Dumping tokens from %s@\n" Sys.argv.(1);
dump_tokens Sys.argv.(1)
